# -*- coding: utf-8 -*-
# @Time    : 2018/4/18 15:40
# @Author  : Soft
# @File    : WorkExecl.py
# @Software: PyCharm
# #Desc    : 作业记录导出导入
from module.ExeclUtils import *


def getWorkExecl(works):
    """
    获取作业记录Execl
    :param works: 作业记录数组
    """
    status = [u'未交', u'已交', u'逾期']
    style = [red, white, yellow]
    book = getWriteBook()
    sheet = book.add_sheet("WORK")
    title = [u'序号', u'课程名', u'学生名', u'提交状态', u'下载地址', u'提交时间']
    for i, v in enumerate(title):
        sheet.write(0, i, v)
    for row, work in zip(range(1, len(works) + 1), works):
        k = work.get('work_status')
        sheet.write(row, 0, row)
        sheet.write(row, 1, work.get('k').get('k_name'))
        sheet.write(row, 2, work.get('stu').get('stu_name'))
        sheet.write(row, 3, status[k], style[k])
        sheet.write(row, 4, work.get('work_url'))
        sheet.write(row, 5, work.get('work_uptime'))
    xls_file = saveTempFile(book, "work.xls")
    return xls_file
